package mapper

import (
	"fmt"
	"gorm.io/gorm"
	"ylb/config"
	"ylb/entity"
	"ylb/tool"
)

type UserReleVanceMapper struct {
	DB *gorm.DB
}

func NewUserReleVanceMapper() UserReleVanceMapper {
	url = config.GetDBUrlConfig()
	userMapper := UserReleVanceMapper{}
	userMapper.DB = tool.GetGormConnection(url)
	return userMapper
}
func (user UserReleVanceMapper) SelectAllRelevanceWithEmail() []entity.UserRelevance {
	var userRelevanceList []entity.UserRelevance
	user.DB.Where("email != ?  ", "").Find(&userRelevanceList)
	fmt.Printf("查到%v\n", len(userRelevanceList))

	return userRelevanceList
}
func (user UserReleVanceMapper) InsertUserRelevance(relevance entity.UserRelevance) int {
	return int(user.DB.Create(&relevance).RowsAffected)
}
